// To parse this JSON data, do
//
//     final momentDetailModel = momentDetailModelFromJson(jsonString);

import 'dart:convert';

import 'package:live_music/models/tag_relation_model.dart';
import 'package:live_music/models/topic_relation_model.dart';

MomentDetailModel momentDetailModelFromJson(String str) =>
    MomentDetailModel.fromJson(json.decode(str));

String momentDetailModelToJson(MomentDetailModel data) =>
    json.encode(data.toJson());

class MomentDetailModel {
  MomentDetailModel({
    this.id,
    this.userId,
    this.type,
    this.textContent,
    this.fileTitle,
    this.activityId,
    this.likeCount,
    this.commentCount,
    this.repostCount,
    this.shareCount,
    this.viewCount,
    this.repostMomentId,
    this.status,
    this.artistId,
    this.ipAddress,
    this.ipSource,
    this.createTime,
    this.updateTime,
    this.userName,
    this.userAvatarUrl,
    this.hasLiked,
    this.hasFollowed,
    this.imageList,
    this.topicList,
    this.tagList,
    this.video,
    this.file,
    this.repostedMoment,
  });

  int id;
  int userId;
  String type;
  String textContent;
  String fileTitle;
  int activityId;
  int likeCount;
  int commentCount;
  int repostCount;
  int shareCount;
  int viewCount;
  int repostMomentId;
  int status;
  int artistId;
  String ipAddress;
  String ipSource;
  DateTime createTime;
  DateTime updateTime;
  String userName;
  String userAvatarUrl;
  bool hasLiked;
  bool hasFollowed;
  List<ImageList> imageList;
  List<TopicRelationModel> topicList;
  List<TagRelationModel> tagList;
  Video video;
  FileClass file;
  MomentDetailModel repostedMoment;

  factory MomentDetailModel.fromJson(Map<String, dynamic> json) =>
      MomentDetailModel(
        id: json["id"] == null ? null : json["id"],
        userId: json["userId"] == null ? null : json["userId"],
        type: json["type"] == null ? null : json["type"],
        textContent: json["textContent"] == null ? null : json["textContent"],
        fileTitle: json["fileTitle"] == null ? null : json["fileTitle"],
        activityId: json["activityId"] == null ? null : json["activityId"],
        likeCount: json["likeCount"] == null ? null : json["likeCount"],
        commentCount:
            json["commentCount"] == null ? null : json["commentCount"],
        repostCount: json["repostCount"] == null ? null : json["repostCount"],
        shareCount: json["shareCount"] == null ? null : json["shareCount"],
        viewCount: json["viewCount"] == null ? null : json["viewCount"],
        repostMomentId:
            json["repostMomentId"] == null ? null : json["repostMomentId"],
        status: json["status"] == null ? null : json["status"],
        artistId: json["artistId"] == null ? null : json["artistId"],
        ipAddress: json["ipAddress"] == null ? null : json["ipAddress"],
        ipSource: json["ipSource"] == null ? null : json["ipSource"],
        createTime: json["createTime"] == null
            ? null
            : DateTime.parse(json["createTime"]),
        updateTime: json["updateTime"] == null
            ? null
            : DateTime.parse(json["updateTime"]),
        userName: json["userName"] == null ? null : json["userName"],
        userAvatarUrl:
            json["userAvatarUrl"] == null ? null : json["userAvatarUrl"],
        hasLiked: json["hasLiked"] == null ? null : json["hasLiked"],
        hasFollowed: json["hasFollowed"] == null ? null : json["hasFollowed"],
        imageList: json["imageList"] == null
            ? null
            : List<ImageList>.from(
                json["imageList"].map((x) => ImageList.fromJson(x))),
        topicList: json["topicList"] == null
            ? null
            : List<TopicRelationModel>.from(
                json["topicList"].map((x) => TopicRelationModel.fromJson(x))),
        tagList: json["tagList"] == null
            ? null
            : List<TagRelationModel>.from(
                json["tagList"].map((x) => TagRelationModel.fromJson(x))),
        video: json["video"] == null ? null : Video.fromJson(json["video"]),
        file: json["file"] == null ? null : FileClass.fromJson(json["file"]),
        repostedMoment: json["repostedMoment"] == null
            ? null
            : MomentDetailModel.fromJson(json["repostedMoment"]),
      );

  Map<String, dynamic> toJson() => {
        "id": id == null ? null : id,
        "userId": userId == null ? null : userId,
        "type": type == null ? null : type,
        "textContent": textContent == null ? null : textContent,
        "fileTitle": fileTitle == null ? null : fileTitle,
        "activityId": activityId == null ? null : activityId,
        "likeCount": likeCount == null ? null : likeCount,
        "commentCount": commentCount == null ? null : commentCount,
        "repostCount": repostCount == null ? null : repostCount,
        "shareCount": shareCount == null ? null : shareCount,
        "viewCount": viewCount == null ? null : viewCount,
        "repostMomentId": repostMomentId == null ? null : repostMomentId,
        "status": status == null ? null : status,
        "artistId": artistId == null ? null : artistId,
        "ipAddress": ipAddress == null ? null : ipAddress,
        "ipSource": ipSource == null ? null : ipSource,
        "createTime": createTime == null ? null : createTime.toIso8601String(),
        "updateTime": updateTime == null ? null : updateTime.toIso8601String(),
        "userName": userName == null ? null : userName,
        "userAvatarUrl": userAvatarUrl == null ? null : userAvatarUrl,
        "hasLiked": hasLiked == null ? null : hasLiked,
        "hasFollowed": hasFollowed == null ? null : hasFollowed,
        "imageList": imageList == null
            ? null
            : List<dynamic>.from(imageList.map((x) => x.toJson())),
        "topicList": topicList == null
            ? null
            : List<dynamic>.from(topicList.map((x) => x.toJson())),
        "tagList": tagList == null
            ? null
            : List<dynamic>.from(tagList.map((x) => x.toJson())),
        "video": video == null ? null : video.toJson(),
        "file": file == null ? null : file.toJson(),
        "repostedMoment":
            repostedMoment == null ? null : repostedMoment.toJson(),
      };
}

class FileClass {
  FileClass({
    this.id,
    this.momentId,
    this.title,
    this.url,
    this.size,
    this.collectCount,
    this.sourceChannel,
    this.sourceUrl,
    this.sourceId,
    this.sequence,
    this.artistId,
    this.createTime,
    this.updateTime,
  });

  int id;
  int momentId;
  String title;
  String url;
  String size;
  dynamic collectCount;
  String sourceChannel;
  String sourceUrl;
  String sourceId;
  int sequence;
  int artistId;
  DateTime createTime;
  DateTime updateTime;

  factory FileClass.fromJson(Map<String, dynamic> json) => FileClass(
        id: json["id"],
        momentId: json["momentId"],
        title: json["title"],
        url: json["url"],
        size: json["size"],
        collectCount: json["collectCount"],
        sourceChannel: json["sourceChannel"],
        sourceUrl: json["sourceUrl"],
        sourceId: json["sourceId"],
        sequence: json["sequence"],
        artistId: json["artistId"],
        createTime: DateTime.parse(json["createTime"]),
        updateTime: DateTime.parse(json["updateTime"]),
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "momentId": momentId,
        "title": title,
        "url": url,
        "size": size,
        "collectCount": collectCount,
        "sourceChannel": sourceChannel,
        "sourceUrl": sourceUrl,
        "sourceId": sourceId,
        "sequence": sequence,
        "artistId": artistId,
        "createTime": createTime.toIso8601String(),
        "updateTime": updateTime.toIso8601String(),
      };
}

class ImageList {
  ImageList({
    this.id,
    this.momentId,
    this.url,
    this.width,
    this.height,
    this.artistId,
    this.createTime,
    this.updateTime,
  });

  int id;
  int momentId;
  String url;
  int width;
  int height;
  int artistId;
  DateTime createTime;
  DateTime updateTime;

  factory ImageList.fromJson(Map<String, dynamic> json) => ImageList(
        id: json["id"],
        momentId: json["momentId"],
        url: json["url"],
        width: json["width"],
        height: json["height"],
        artistId: json["artistId"],
        createTime: DateTime.parse(json["createTime"]),
        updateTime: DateTime.parse(json["updateTime"]),
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "momentId": momentId,
        "url": url,
        "width": width,
        "height": height,
        "artistId": artistId,
        "createTime": createTime.toIso8601String(),
        "updateTime": updateTime.toIso8601String(),
      };
}

class Video {
  Video({
    this.id,
    this.momentId,
    this.title,
    this.url,
    this.width,
    this.height,
    this.size,
    this.coverUrl,
    this.coverWidth,
    this.coverHeight,
    this.collectCount,
    this.sourceChannel,
    this.sourceUrl,
    this.sourceId,
    this.sequence,
    this.artistId,
    this.createTime,
    this.updateTime,
    this.hasCollected,
  });

  int id;
  int momentId;
  String title;
  String url;
  int width;
  int height;
  String size;
  String coverUrl;
  int coverWidth;
  int coverHeight;
  int collectCount;
  String sourceChannel;
  String sourceUrl;
  String sourceId;
  int sequence;
  int artistId;
  DateTime createTime;
  DateTime updateTime;
  bool hasCollected;

  factory Video.fromJson(Map<String, dynamic> json) => Video(
        id: json["id"] == null ? null : json["id"],
        momentId: json["momentId"],
        title: json["title"],
        url: json["url"],
        width: json["width"] == null ? null :  json["width"],
        height: json["height"] == null ? null : json["height"],
        size: json["size"]== null ? null :json["size"],
        coverUrl: json["coverUrl"],
        coverWidth: json["coverWidth"]  == null ? null :  json["coverWidth"],
        coverHeight: json["coverHeight"]  == null ? null : json["coverHeight"] ,
        collectCount: json["collectCount"]  == null ? null :  json["collectCount"] ,
        sourceChannel: json["sourceChannel"],
        sourceUrl: json["sourceUrl"]  == null ? null : json["sourceUrl"],
        sourceId: json["sourceId"],
        sequence: json["sequence"] == null ? null : json["sequence"] ,
        artistId: json["artistId"],
        createTime: DateTime.parse(json["createTime"]),
        updateTime: DateTime.parse(json["updateTime"]),
        hasCollected: json["hasCollected"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "momentId": momentId,
        "title": title,
        "url": url,
        "width": width,
        "height": height,
        "size": size,
        "coverUrl": coverUrl,
        "coverWidth": coverWidth,
        "coverHeight": coverHeight,
        "collectCount": collectCount,
        "sourceChannel": sourceChannel,
        "sourceUrl": sourceUrl,
        "sourceId": sourceId,
        "sequence": sequence,
        "artistId": artistId,
        "createTime": createTime.toIso8601String(),
        "updateTime": updateTime.toIso8601String(),
        "hasCollected": hasCollected,
      };
}
